#include "postmessagestatusresponse.h"


PostMessageStatusResponse::PostMessageStatusResponse(QObject *parent)
    : Network::JSONResponse(parent)
    , m_isUpdateSuccess(false)
{
}

void PostMessageStatusResponse::parse(const QVariant &data)
{
    if (data.type() != QVariant::Map) {
        setError(Response::Property, "The field of \"map\" isn't a map");
        return;
    }

    QVariantMap map = data.toMap();
    if (!map.contains("key")) {
        setError(Response::Property, "The field of \"key\" is missing");
        return;
    }

    if (!map.contains("userIdFrom")) {
        setError(Response::Property, "The field of \"userIdFrom\" is missing");
        return;
    }

    if (!map.contains("type")) {
        setError(Response::Property, "The field of \"type\" is missing");
        return;
    }

    if (!map.contains("createdTime")) {
        setError(Response::Property, "The field of \"createdTime\" is missing");
        return;
    }

    if (!map.contains("comment")) {
        setError(Response::Property, "The field of \"comment\" is missing");
        return;
    }

    if (!map.contains("totalCmt")) {
        setError(Response::Property, "The field of \"totalCmt\" is missing");
        return;
    }

    if (!map.contains("numLike")) {
        setError(Response::Property, "The field of \"numLike\" is missing");
        return;
    }

    m_isUpdateSuccess = true;

    emit postMessageStatusSuccess();
}
